import request from '@/utils/request'

export function fetchList(data) {
  return request({
    url: '/system/sys/user/list',
    method: 'post',
    data,
  })
}

export function fetchUser(id) {
  return request({
    url: '/system/sys/user/detail/' + id,
    method: 'get',
  })
}

export function createUser(data) {
  return request({
    url: '/system/sys/user/add',
    method: 'post',
    data,
    headers: {
      'Content-Type': undefined,
    },
    transformRequest: [
      (data, headers) => {
        return data
      },
    ],
  })
}

export function updateUser(data) {
  return request({
    url: '/system/sys/user/update',
    method: 'post',
    data,
    headers: {
      'Content-Type': undefined,
    },
    transformRequest: [
      (data, headers) => {
        return data
      },
    ],
  })
}

export function deleteUser(id) {
  return request({
    url: '/system/sys/user/delete/' + id,
    method: 'post',
  })
}

export function modifyPassword(data) {
  return request({
    url: '/system/sys/user/' + data.id + '/changePassword',
    method: 'post',
    data,
  })
}

export function exportUser(query) {
  return request({
    url: '/system/sys/user/export',
    method: 'get',
    params: query,
  })
}

export function myUpdateUser(data) {
  return request({
    url: '/system/sys/user/my/update',
    method: 'post',
    data,
  })
}

export function myUpdateChangePassword(data) {
  return request({
    url: '/system/sys/user/my/changePassword',
    method: 'post',
    data,
  })
}

export function getInfo() {
  return request({
    url: '/system/sys/user/info',
    method: 'get',
  })
}
export function getinfoImages() {
  return request({
    url: '/system/sys/user/infoImages',
    method: 'get',
  })
}
export function geturl({ params }) {
  console.log(params)
  return request({
    url: `/system/attachment/get/portrait/url/${params.userId}`,
    method: 'get',
  })
}
export function getconfigUrl({ params }) {
  console.log(params)
  return request({
    url: `/system/attachment/get/system/config/url/${params.userId}`,
    method: 'get',
  })
}
